﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DeliverGoodsManagement_PrintWindow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hidExpressBillImagePath.Value = BLL.Common.GetExpressPicPath();
            Ajax.Utility.RegisterTypeForAjax(typeof(DeliverGoodsManagement_PrintWindow));
        }
    }

    #region 返回前台初始化数据
    [Ajax.AjaxMethod]
    public DataSet GetData(string value)
    {
        string[] id = value.Split('_');
        if (id[2] != "")
        {
            try
            {
                string strOrderId = id[2].Replace("|", ",");
                DataSet ds = new BLL.ORDERDOC().GetOrderToPrintByTranerIdAndTemplateId(id[0], id[1], strOrderId);
                DataTable dt = new DataTable();

                foreach (DataColumn col in ds.Tables[2].Columns)
                {
                    DataColumn c = new DataColumn();
                    c.ColumnName = col.ColumnName;
                    c.DataType = col.DataType;
                    dt.Columns.Add(c);
                }
                foreach (DataRow row in ds.Tables[2].Rows)
                {
                    DataRow r = dt.NewRow();
                    for (int i = 0; i < ds.Tables[2].Columns.Count; i++)
                    {
                        r[i] = row[i];
                    }
                    dt.Rows.Add(r);
                }
                ds.Tables[2].Clear();
                string[] arrTmp = strOrderId.Split(',');
                foreach (string orderid in arrTmp)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        if (row["ORDER_ID"].ToString() == orderid)
                        {
                            DataRow r = ds.Tables[2].NewRow();
                            for (int i = 0; i < dt.Columns.Count; i++)
                            {
                                r[i] = row[i];
                            }
                            ds.Tables[2].Rows.Add(r);
                        }
                    }
                }
                return ds;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        else
        {
            DataSet ds = new BLL.ORDERDOC().GetOrderToPrintByTranerIdAndTemplateId(id[0], id[1]);
            return ds;
        }
            
        
    }
    #endregion
}
